{include file='common/head.html'}

<div class="layui-body">
    {if([$list])}
    <div class="layui-tab layui-tab-brief" lay-filter="tab">
        <ul class="layui-tab-title">
            <li class="layui-this" lay-id="t1">激活码列表</li>
            <li lay-id="t2">激活码新增</li>
        </ul>
        <div class="layui-tab-content">
            <div class="layui-tab-item layui-show">
                <form action="{url./admin/Member/index}" method="get" class="layui-form">
                    <div class="layui-form-item nospace">
                        <div class="layui-input-inline">
                            {$pathinfo}
                            <select name="field" lay-verify="required">
                                <option value="code" {if(get('field')=='code')}selected="selected" {/if}>激活码</option>
                                <option value="a.usermobile" {if(get('field')=='a.usermobile')}selected="selected" {/if}>会员名称</option>


                            </select>
                        </div>
                        <div class="layui-input-inline">
                            <input type="text" name="keyword" value="{$get.keyword}" placeholder="请输入搜索关键字"
                                   class="layui-input">
                        </div>
                        <div class="layui-input-inline">
                            <button class="layui-btn" lay-submit>搜索</button>
                            <a class="layui-btn layui-btn-primary" href="{url./admin/Member/Activation}">清除搜索</a>
                        </div>
                    </div>
                </form>

                <form action="{url./admin/Member/mod}" method="post" id="contentForm" name="contentForm"
                      class="layui-form" onkeydown="if(event.keyCode==13) return false;">
                    <input type="hidden" name="formcheck" value="{$formcheck}">
                    <table class="layui-table">
                        <thead>
                        <tr>
                            <th><input type="checkbox" class="checkbox" lay-ignore id="checkall" title="全选"></th>
                            <th>编号</th>
                            <th>拥有者</th>
                            <th>使用者</th>
                            <th>激活码</th>
                            <th>状态</th>
                            <th>来源</th>
                            <th>使用时间</th>
                            <th>添加时间</th>
                            <th>操作</th>
                        </tr>
                        </thead>
                        <tbody>
                        {foreach $ActCode(key,value)}
                        <tr>
                            <td>
                                <input type="checkbox" class="checkbox checkitem" lay-ignore name="list[]"
                                       value="[value->id]">
                                <input type="hidden" name="listall[]" value="[value->id]">
                            </td>
                            <td>[value->id]</td>
                            <td>[value->usermobile]</td>
                            <td>
                                {if($value->username ==null)}
                                暂未激活
                                {else}
                                [value->username]
                                {/if}
                            </td>
                            <td>[value->code]</td>

                            <td>
                                {if($value->status ==1)}
                                未使用
                                {else}
                                已使用
                                {/if}
                            </td>
                            <td>[value->source]</td>
                            <td>[value->ues_time]</td>
                            <td>[value->add_time]</td>
                            <td>

                                {fun=get_btn_del($value->id)}

                            </td>
                        </tr>

                        {/foreach}
                        </tbody>
                    </table>

                    {if([$ActCode])}
                    <div class="layui-btn-group">
                        {if(check_level('del'))}
                        <button type="submit" name="submit" onclick="return setDelAction();"
                                class="layui-btn layui-btn-sm">删除
                        </button>
                        {/if}


                    </div>
                    <script>
                        function setDelAction() {
                            document.contentForm.action = "{url./admin/Activation/del}";
                            return confirm("您确定要删除选中的激活码么？");
                        }
                    </script>
                    {/if}
                </form>
                <div class="page">{$pagebar}</div>
            </div>
            <div class="layui-tab-item">
                <form action="{url./admin/Activation/add}" method="post" class="layui-form">
                    <input type="hidden" name="formcheck" value="{$formcheck}">

                    <!--<div id="add">-->
                        <!--<div class="layui-form-item">-->
                            <!--<label class="layui-form-label">激活码<span class="layui-text-red">*</span></label>-->
                            <!--<div class="layui-input-inline">-->
                                <!--<input type="text" name="code[]" id="code"  class="layui-input layui-disabled" autocomplete="off" >-->
                            <!--</div>-->
                            <!--<button type="button" class="layui-btn " onclick="AddCode();" data-des="headpic">-->
                                <!--<i class="layui-icon">&#xe9aa;</i>生成激活码-->
                            <!--</button>-->
                            <!--<i class="layui-icon" id="clickAdd">&#xe624;</i>-->
                        <!--</div>-->

                    <!--</div>-->
                    <div class="layui-form-item">
                        <label class="layui-form-label">数量<span class="layui-text-red">*</span></label>
                        <div class="layui-input-inline">
                            <input type="number" name="number"  min=1   lay-verify="required"  autocomplete="off"  class="layui-input " placeholder="请输入数量" >
                        </div>
                    </div>
                    <div class="layui-form-item">
                        <label class="layui-form-label">用户手机号码<span class="layui-text-red">*</span></label>
                        <div class="layui-input-inline">
                            <input type="text" name="usermobile" required    lay-verify="required"  autocomplete="off"  class="layui-input " placeholder="请输入用户手机号码" >
                        </div>
                    </div>
                    <div class="layui-form-item">
                        <div class="layui-input-block">
                            <button class="layui-btn" lay-submit>立即提交</button>
                            <button type="reset" class="layui-btn layui-btn-primary">重置</button>
                        </div>
                    </div>
                </form>
            </div>
        </div>
    </div>
    {/if}



</div>
<script>
//     var btn = document.getElementById("clickAdd");
//     btn.onclick = function () {
//         var html = '';
// //动态添加一个表格
//         html += '  <div class="layui-form-item deiCode" id="">';
//         html += '  <label class="layui-form-label">激活码<span class="layui-text-red">*</span></label>';
//         html += ' <div class="layui-input-inline"> ';
//         html += ' <input type="text" name="code[]" required  lay-verify="required"  autocomplete="off"   class="layui-input layui-disabled">';
//         html += ' </div>';
//         html += '  <button type="button" class="layui-btn "  onclick="AddCode();"data-des="headpic">';
//         html += '   <i class="layui-icon">&#xe9aa;</i>生成激活码';
//         html += ' </button>';
//         html += ' <i class="layui-icon" id="clickdei">&#xe67e;</i>';
//         $('#add').append(html);
//         var clickdei = document.getElementById("clickdei");
//         clickdei.onclick = function () {
//             $(".deiCode").remove();
//         }
//     }
//
//     function AddCode() {
//         layui.use('layer', function () {
//             $.ajax({
//                 type: "POST",                  //提交方式
//                 url: '{url./admin/Activation/CreateCode}',   //接口路径TP是（模块/控制器/方法）
//                 dataType: "json",             //数据格式
//                 success: function (data) {
//
//                     if (data.code == 1) {
//                         $("#code").attr("value", data.data);
//                     }
//
//                 }
//             });
//
//
//         });
//
//     }
</script>
<script>


</script>
{include file='common/foot.html'}
